home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Visual Database
/
Visual dBase v5.5
/
SAMPLES1.PAK
/
NAMEINFO.WFM
< prev
next >
Wrap
Text File
|
1995-07-18
|
14KB
|
519 lines
******************************************************************************
* PROGRAM: Nameinfo.wfm
*
* WRITTEN BY: Borland Samples Group
*
* DATE: 12/93
*
* UPDATED: 5/95
*
* REVISION: $Revision: 1.26 $
*
* VERSION: Visual dBASE
*
* DESCRIPTION: This program shows the DDE capabilities of Visual dBASE. It
* establishes a link with WordPerfect to create a "Thank you"
* letter for customers that purchased software.
*
* PARAMETERS: None
*
* CALLS: Namesrch.wfm (Search form)
* Buttons.cc (Custom Controls file)
* Names.qbe (View of table)
*
* USAGE: DO Nameinfo.wfm
*
*******************************************************************************
#include "Messdlg.h"
create session
set talk off
set ldCheck off
** END HEADER -- do not remove this line*
* Generated on 07/11/95
*
parameter bModal
local f
f = new NAMEINFOFORM()
if (bModal)
f.mdi = .F. && ensure not MDI
f.ReadModal()
else
f.Open()
endif
CLASS NAMEINFOFORM OF FORM
Set Procedure To &_dbwinhome.samples\BUTTONS.CC additive
this.OnOpen = CLASS::FORM_ONOPEN
this.Width = 61.166
this.View = "NAMES.QBE"
this.OnClose = {;close procedure &_dbwinhome.samples\Buttons.cc}
this.Top = 2.0586
this.MousePointer = 1
this.Left = 16.166
this.ColorNormal = "BtnText/BtnFace"
this.Text = "WordPerfect Merge"
this.Height = 17.1758
this.Maximize = .F.
this.Minimize = .F.
DEFINE RECTANGLE MERGERECT OF THIS;
PROPERTY;
Width 46,;
Text "",;
Height 17.1758,;
BorderStyle 1
DEFINE TEXT TITLETEXT OF THIS;
PROPERTY;
Width 10.5059,;
FontSize 4,;
Top 0.5391,;
Left 1.1592,;
Text "Title:",;
Height 1.0488,;
FontBold .F.
DEFINE TEXT FIRSTNAMETEXT OF THIS;
PROPERTY;
Width 9.5508,;
Top 0.5391,;
Left 12.4482,;
Text "First name:",;
Height 1.0488,;
FontBold .F.
DEFINE TEXT LASTNAMETEXT OF THIS;
PROPERTY;
Width 9.7969,;
Top 0.5391,;
Left 32.8682,;
Text "Last name:",;
Height 1.0488,;
FontBold .F.
DEFINE TEXT ADDRESSTEXT OF THIS;
PROPERTY;
Width 8.5059,;
Top 3.2598,;
Left 1.1592,;
Text "Address:",;
Height 1.0342,;
FontBold .F.
DEFINE TEXT CITYTEXT OF THIS;
PROPERTY;
Width 6.5059,;
Top 6.0596,;
Left 1.1592,;
Text "City:",;
Height 1.1162,;
FontBold .F.
DEFINE TEXT STATETEXT OF THIS;
PROPERTY;
Width 5.1006,;
Top 6.0596,;
Left 24.3984,;
Text "State:",;
Height 1.1162,;
FontBold .F.
DEFINE TEXT ZIPCODETEXT OF THIS;
PROPERTY;
Width 10.4561,;
Top 6.0596,;
Left 30.21,;
Text "Zip Code:",;
Height 1.1162,;
FontBold .F.
DEFINE TEXT PHONETEXT OF THIS;
PROPERTY;
Width 6.5059,;
Top 8.7988,;
Left 1.1592,;
Text "Phone:",;
Height 1.083,;
FontBold .F.
DEFINE TEXT PRODUCTTEXT OF THIS;
PROPERTY;
Width 7.8398,;
Top 11.5186,;
Left 1.1592,;
Text "Product:",;
Height 1.0693,;
FontBold .F.
DEFINE ENTRYFIELD FIRSTNAMEENTRY OF THIS;
PROPERTY;
Width 15.2061,;
Top 1.6094,;
Left 10.46,;
Height 1.3311,;
DataLink "NAMES->FNAME"
DEFINE ENTRYFIELD LASTNAMEENTRY OF THIS;
PROPERTY;
Width 19.4355,;
Top 1.6094,;
Left 26.2295,;
Height 1.3311,;
DataLink "NAMES->LNAME"
DEFINE ENTRYFIELD ADDRESSENTRY OF THIS;
PROPERTY;
Width 44.5059,;
Top 4.3887,;
Left 1.1592,;
Height 1.376,;
DataLink "NAMES->ADDRESS"
DEFINE ENTRYFIELD CITYENTRY OF THIS;
PROPERTY;
Width 22.3398,;
Top 7.1299,;
Left 1.1592,;
Height 1.3398,;
DataLink "NAMES->CITY"
DEFINE ENTRYFIELD STATEENTRY OF THIS;
PROPERTY;
Width 3.7656,;
Top 7.1299,;
Left 24.3984,;
Function "!",;
Height 1.3398,;
DataLink "NAMES->STATE",;
Picture "AA"
DEFINE ENTRYFIELD ZIPENTRY OF THIS;
PROPERTY;
Width 15.4561,;
Top 7.1299,;
Left 30.21,;
Height 1.3398,;
DataLink "NAMES->ZIP",;
Picture "99999"
DEFINE ENTRYFIELD PHONEENTRY OF THIS;
PROPERTY;
Width 22.3398,;
Top 9.8594,;
Left 1.1592,;
Function "R(999)999-9999",;
Height 1.375,;
DataLink "NAMES->PHONE",;
Picture "(999)999-9999"
DEFINE ENTRYFIELD PRODUCTENTRY OF THIS;
PROPERTY;
Width 44.5059,;
Top 12.6592,;
Left 1.1592,;
Height 1.3408,;
DataLink "NAMES->PRODUCT"
DEFINE PUSHBUTTON NEWBUTTON OF THIS;
PROPERTY;
Width 14.1729,;
Group .T.,;
Top 15.0889,;
Left 1.1592,;
ColorNormal "",;
Text "&New",;
Height 1.5576,;
OnClick {;append blank;go bottom},;
Default .T.
DEFINE PUSHBUTTON SEARCHBUTTON OF THIS;
PROPERTY;
Width 14.2354,;
Group .T.,;
Top 15.0889,;
Left 16.4297,;
ColorNormal "",;
Text "&Search",;
Height 1.5576,;
OnClick CLASS::SEARCHBUTTON_ONCLICK
DEFINE PUSHBUTTON MERGEBUTTON OF THIS;
PROPERTY;
Width 14.127,;
Group .T.,;
Top 15.0889,;
Left 31.5391,;
ColorNormal "",;
Text "&Merge",;
Height 1.5576,;
OnClick CLASS::MERGEBUTTON_ONCLICK
DEFINE OKBUTTON OKINFOBUTTON OF THIS;
PROPERTY;
Width 14.1338,;
Group .T.,;
Top 1.0684,;
Left 46.6982,;
Height 1.5195,;
OnClick CLASS::OKINFO_ONCLICK
DEFINE CANCELBUTTON CANCELINFOBUTTON OF THIS;
PROPERTY;
Width 14.1338,;
Group .T.,;
Top 3,;
Left 46.6982,;
Height 1.5293,;
OnClick CLASS::CANCELINFO_ONCLICK
DEFINE SAMPLEINFOBUTTON NAMEINFOINFOBUTTON OF THIS;
PROPERTY;
Width 3.665,;
Group .T.,;
Top 16,;
Left 57.5,;
Height 1.1758
Procedure Form_OnOpen
****************************************************************************
form.stateEntry.Width = 3.96
form.zipEntry.Width = 10.56
form.titles = new array(5)
form.titles[1] = "Mr."
form.titles[2] = "Mrs."
form.titles[3] = "Ms."
form.titles[4] = "Dr."
form.titles[5] = "Rev."
DEFINE COMBOBOX TitleCombo OF THIS;
PROPERTY;
Width 7.92,;
Top 1.66,;
Left 1.32,;
Height 1.66,;
Style 2,;
DataLink "NAMES->TITLE",;
DataSource "ARRAY form.titles"
this.netobj = NEW NETLOCKS ()
form.nameInfoInfoButton.sampleName = "Nameinfo.wfm"
****************************************************************************
Procedure OKINFO_OnClick
****************************************************************************
local result
if form.netobj.reclock()
result = commit()
flush
go top
else
AlertMessage("Warning","Your record was not locked. No data will be saved!")
endif
if dbf() = "NAMES"
use
endif
form.Close()
****************************************************************************
Procedure CANCELINFO_OnClick
****************************************************************************
if form.netobj.reclock()
rollback()
else
AlertMessage("Warning","No data was saved!")
endif
if alias() = "NAMES"
use
endif
form.Close()
****************************************************************************
Procedure SEARCHBUTTON_OnClick
* Open the search dialog box modal
****************************************************************************
local srch
set procedure to &_dbwinhome.samples\Namesrch.wfm additive
srch = NEW NAMESRCHFORM ()
srch.mdi = .F.
srch.readModal()
close procedure &_dbwinhome.samples\Namesrch.wfm
****************************************************************************
Procedure MERGEBUTTON_OnClick
****************************************************************************
* Macro substitution for International translation
fld1 = field(1)
fld4 = field(4)
fld9 = field(9)
myLink = new DdeLink (form)
if MyLink.initiate("WPWin60_Macros","commands")
* If WordPerfect is already running
*MyLink.execute('FileOpen (Filename:"DDETEST.wpd",4)')
ok2exec = .T.
else
* If WordPerfect has to be started
* object.initiate("appname","filename")
* This will start WordPerfect with file: DDETEST
* DDETEST.WPD has to exist in the WordPerfect Path
*MyLink.initiate("c:\wpwin60\wpwin","ddetest.wpd")
MyLink.initiate("c:\wpwin60\wpwin","")
* This is required to go into command mode
if MyLink.initiate("WPWin60_Macros","commands")
ok2exec = .T.
else
AlertMessage("Unable to establish DDE Link. Start WordPerfect.","DDE Warning")
ok2exec = .F.
endif
endif
if ok2exec
ddeName = 'Type ({"'+FORMNAME()+'"})' && Proper name
ddeAddress = 'Type ({"'+&FLD4+'"})' && Street Address
ddeCity = 'Type ({"'+FORMCITY()+'"})' &&Formatted City, State & Zip
ddeSalutation = 'Type ({"'+FMTSTR("Dear %S:",TRIM(&FLD1))+'"})'
ddeProduct = 'Type ({"'+FMTSTR("Congratulations on purchasing %S!",TRIM(&FLD9))+'"})'
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"DateText()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,ddeName)
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,ddeAddress)
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,ddeCity)
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,ddeSalutation)
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,ddeProduct)
ExecuteLink(Mylink,'Type ({" We trust that using this software will be fun and exciting."})')
ExecuteLink(Mylink,'Type ({"We hope you will continue to use our products."})')
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,'Type ({"Sincerely,"})')
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,'Type ({"Programmer"})')
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,'Type ({"DDE Person"})')
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,"HardReturn()")
ExecuteLink(Mylink,'Type ({"dFW:TJC"})')
ExecuteLink(Mylink,"Filesave(Filename: 'ddetest'; ExportType: 4; Overwrite: Yes!)")
ExecuteLink(Mylink,"Close (Save: 1)")
endif &&ok2execute
MyLink.terminate()
ENDCLASS
*******************************************************************************
*******************************************************************************
CLASS NETLOCKS
*******************************************************************************
*******************************************************************************
Function RecLock
*******************************************************************************
local cnt, isLocked
cnt = 1
isLocked = .F.
do while .not. isLocked .and. cnt < 11
isLocked = rlock()
cnt = cnt + 1
enddo
return isLocked
ENDCLASS
*******************************************************************************
Function FormName
*******************************************************************************
local fmtLine
fmtLine = "%1 %2 %3"
fld1 = field(1)
fld2 = field(2)
fld3 = field(3)
return Fmt3Str(fmtLine,iif(empty(&fld3),"",trim(&fld3)),trim(&fld1),&fld2)
*******************************************************************************
Function FormCity
*******************************************************************************
local fmtLine
fmtLine = "%1, %2 %3"
fld5 = field(5)
fld6 = field(6)
fld7 = field(7)
return Fmt3Str(fmtLine,trim(&fld5),&fld6,&fld7)
*******************************************************************************
Function FmtStr(string, repStr)
* replaces "%S" with replacement string
*******************************************************************************
return stuff(string, at("%S", string), 2, repStr)
*******************************************************************************
Function Fmt3Str(string, rep1, rep2, rep3)
*******************************************************************************
local i
for i = 1 to 3
do case
case i = 1
string = stuff(string, at("%1",string),2,rep1)
case i = 2
string = stuff(string, at("%2",string),2,rep2)
case i = 3
string = stuff(string, at("%3",string),2,rep3)
endcase
next
return string
*******************************************************************************
Procedure ExecuteLink(link, string)
*******************************************************************************
link.execute(ansi(string))